<template>
  <div class="editable-cell">
    <DFFormItem
      :schema="props.column?.itemData"
      :formModel="props?.record"
      :field="props.column?.key"
      :isEditTable="true"
      :table="table"
      @setFieldsValueFn="setFieldsValueFn"
    />
  </div>
</template>
<script lang="ts" setup>
  import DFFormItem from '@/components/DFForm/src/Item.vue';

  import { useTableContext } from '../../hooks/useTableContext';

  type Props = {
    value?: any;
    record?: any;
    column?: any;
    index?: any;
  };

  const props: any = withDefaults(defineProps<Props>(), {
    record: () => ({}),
    column: () => ({}),
    value: () => null,
    index: () => null,
  });

  const table: any = useTableContext();

  const setFieldsValueFn = (obj) => {
    table.setEditTableDataFn({
      record: props.record,
      index: props.index,
      key: props.column?.key,
      value: obj[props.column?.key] === null ? props.column?.itemData?.component === "NInputNumber"? undefined : null : obj[props.column?.key],
      data: obj,
    });
  };

  // console.log(props.column);
</script>

<style lang="less">
  // .editable-cell {

  // }
</style>
